/*
*   Packet.h
*   Authors: Dustin Striplin
*   Contains information that is nessecary for the UI to update.
                    P3 - running
                    I/O1 - P2, P5 waiting
                    M1 - P6 owns, P7 waiting
                    K - P13 waiting
                    CV1 - Cond 0, P1, P9 waiting
                    ---------------------------------
                    Timer interrupt
                    P3 returned to ready queue
                    P1 selected from queue
                    P1 - running

                    IO interrupt
                    device number
                    P2 returned to ready queue
                    P3 running

                    IO request
                    device number
                    P2 added to blocked queue
                    Px running



*/

#ifndef PACKET_H
#define PACKET_H

#include "global.h"
#include "IOdevice.h"
#include "Queue.h"
#include "Mutex.h"
#include "ConditionVariable.h"

typedef struct packet{
    int type; //the type of request/interrupt
    int requestID; //the number of the item that is interrupting/being requested
    int consumersValue; //the value that the consumer read, equal to NO_ID if not set
    int runningProcess;
    int keyBoard; //what process is waiting on the keyboard
    int readyQueueSize;
    int numProducerConsumer;
    int* readyQueue;//array that contains the ready queue pcb id's
    int* mutexOwners; //the owners of the mutexes
    int** deviceQueues;//2d array that contains all of the device Queues info
    int** mutexQueues;//2d array that contains all of the mutex info
    int** conditionQueues;//2d array that contains all of the condition variable queues


    void(*destruct)(struct packet*);
}PacketStr;

typedef PacketStr* PacketPtr;

PacketPtr packetConstructor(int type, int requestID, int runningProcess, int kb, QueuePtr rq, IODevicePtr* devices, MutexPtr* mutexes, CVPtr* condVars, int numProducerConsumer);
void packetDestructor(PacketPtr this);
void populateDeviceQueue(PacketPtr this, IODevicePtr* devices);
void populateReadyQueue(PacketPtr this, QueuePtr rq);
void populateMutexQueues(PacketPtr this, MutexPtr* mutexes);
void populateConditionQueues(PacketPtr this, CVPtr* condVars);



//constructor

//destructor


#endif
